package com.itheima.modifier;

public class Father {

    //1.private：私有权限修饰符，只能在本类中访问
    private void privateMethod() {
        System.out.println("privateMethod");
    }

    //2.缺省：只能在本包中访问
    void defaultMethod() {
        System.out.println("defaultMethod");
    }


    //3.protected：受保护权限修饰符，只能在本包中和子孙类(同包或不同包)中访问
    protected void protectedMethod() {
        System.out.println("protectedMethod");
    }

    //4.public：公共权限修饰符，在任何地方都可以访问
    public void publicMethod() {
        System.out.println("publicMethod");
    }

    public static void main(String[] args) {
        //同一个类中
        Father father = new Father();
        father.privateMethod();
        father.defaultMethod();
        father.protectedMethod();
        father.publicMethod();
    }
}
